package com.woniuxy.microuserserver.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.microcommonserver.bean.user_hpd.ScoreDetail;
import com.woniuxy.microcommonserver.pageHelper.PageRequest;
import com.woniuxy.microuserserver.mapper.UserScoreMapper;
import com.woniuxy.microuserserver.service.IUserScoreService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;

@Service
@Transactional(readOnly = true)
public class UserScoreServiceImpl implements IUserScoreService {
    @Resource
    private UserScoreMapper userScoreMapper;

    @Override
    public PageInfo<ScoreDetail> findDetailByParam(PageRequest request, Date startTime, Date endTime) {
        return PageHelper.startPage(request.getPageNum(),request.getLimit()).
                doSelectPageInfo(()->userScoreMapper.findDetailByParam(request,startTime,endTime));
    }

    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
    @Override
    public void addScoreDetail(ScoreDetail scoreDetail) {
        userScoreMapper.addScoreDetail(scoreDetail);
    }

}
